// adapter/rest/BorrowRecordResponse.java
package com.library.bookservice.adapter.rest;

import com.library.bookservice.domain.model.BorrowRecord;
import java.time.LocalDateTime;

/**
 * 借阅记录响应DTO
 */
public record BorrowRecordResponse(
        Long id,
        Long bookId,
        String borrowerName,
        String borrowerPhone,
        LocalDateTime borrowDate,
        LocalDateTime returnDate,
        boolean returned
) {
    public static BorrowRecordResponse from(BorrowRecord record) {
        return new BorrowRecordResponse(
                record.getId(),
                record.getBookId(),
                record.getBorrowerName(),
                record.getBorrowerPhone(),
                record.getBorrowDate(),
                record.getReturnDate(),
                record.isReturned()
        );
    }
}